package com.mask.sca.system.controller;

import com.mask.sca.system.entity.Role;
import com.mask.sca.system.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @GetMapping("/list")
    public List<Role> list() {
        return roleService.list();
    }

    @GetMapping("/{id}")
    public Role get(@PathVariable Long id) {
        return roleService.getById(id);
    }

    @PostMapping("/add")
    public boolean add(@RequestBody Role role) {
        return roleService.save(role);
    }

    @PutMapping("/update")
    public boolean update(@RequestBody Role role) {
        return roleService.updateById(role);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return roleService.removeById(id);
    }
} 